/**
 * 静态资源管理
 * 用于统一管理应用中的静态资源路径
 */

// 默认图片
export const DEFAULT_IMAGES = {
  AVATAR: '/static/images/default-avatar.png',
  PRODUCT: '/static/images/default-product.png',
  BANNER: '/static/images/default-banner.png',
  LOGO: '/static/images/logo.png',
  EMPTY: '/static/images/empty.png'
}

// TabBar图标
export const TAB_ICONS = {
  HOME: '/static/tabbar/home.png',
  HOME_ACTIVE: '/static/tabbar/home-active.png',
  CATEGORY: '/static/tabbar/category.png',
  CATEGORY_ACTIVE: '/static/tabbar/category-active.png',
  CART: '/static/tabbar/cart.png',
  CART_ACTIVE: '/static/tabbar/cart-active.png',
  MESSAGE: '/static/tabbar/message.png',
  MESSAGE_ACTIVE: '/static/tabbar/message-active.png',
  PROFILE: '/static/tabbar/profile.png',
  PROFILE_ACTIVE: '/static/tabbar/profile-active.png'
}

// 分类图标
export const CATEGORY_ICONS = {
  FOOD: '/static/category/food.png',
  DAILY: '/static/category/daily.png',
  CLOTHES: '/static/category/clothes.png',
  ELECTRONICS: '/static/category/electronics.png',
  BEAUTY: '/static/category/beauty.png',
  BABY: '/static/category/baby.png',
  SPORTS: '/static/category/sports.png',
  HOME: '/static/category/home.png',
  AUTO: '/static/category/auto.png',
  ALL: '/static/category/all.png'
}

// 获取图片完整路径
export const getImageUrl = (path) => {
  if (!path) return DEFAULT_IMAGES.PRODUCT
  if (path.startsWith('http')) return path
  if (path.startsWith('/')) return path
  return `/static/images/${path}`
}

// 获取分类图标
export const getCategoryIcon = (code) => {
  const iconMap = {
    food: CATEGORY_ICONS.FOOD,
    daily: CATEGORY_ICONS.DAILY,
    clothes: CATEGORY_ICONS.CLOTHES,
    electronics: CATEGORY_ICONS.ELECTRONICS,
    beauty: CATEGORY_ICONS.BEAUTY,
    baby: CATEGORY_ICONS.BABY,
    sports: CATEGORY_ICONS.SPORTS,
    home: CATEGORY_ICONS.HOME,
    auto: CATEGORY_ICONS.AUTO,
    all: CATEGORY_ICONS.ALL
  }
  
  return iconMap[code] || CATEGORY_ICONS.ALL
}